package com.qg.cyapp.util;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.DialogInterface;
import android.util.Log;

/**
 * 警告框提醒
 * 
 * @author ZZJ
 * 
 */
public class MyAlertDialog {

	private AlertDialog.Builder builder;
	
	public MyAlertDialog(Activity activity){
		builder = new Builder(activity);
	}
	
	public void show(String strTitle,final MyCallBack myCallBack,boolean showNegativeButton) {
		builder.setTitle(strTitle);
		builder.setPositiveButton("确认", new DialogInterface.OnClickListener() {
			public void onClick(DialogInterface dialog, int which) {
				Log.v("DialogInterface onClick", ""+which);
				if(myCallBack!=null){
					myCallBack.doAfter();
				}
				dialog.dismiss();
			}
		});
		if(showNegativeButton){
			builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
				public void onClick(DialogInterface dialog, int which) {
					Log.v("DialogInterface onClick", ""+which);
					dialog.dismiss();
				}
			});
		}
		
		builder.create().show();
	}
	
	public interface MyCallBack{
		void doAfter();
	}
}


